package service.impl;

import entity.User;
import service.UserService;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
 * @Author Corday 天涯
 * @Date 2022/3/8 10:51
 */
public class UserServiceImpl implements UserService {
    @Override
    public List<User> findUsers() {
        List<User> users = new ArrayList<>();
        users.add(new User(801,"tom","1234",1));
        users.add(new User(802,"bean","1234",2));
        users.add(new User(803,"mary","1234",1));
        return users;
    }

    @Override
    public User findUserByUid(int uid) {
        return new User(201,"nick123","1234",1);
    }

    @Override
    public User findUserByUsername(String username) {
        //此处要校验username是否合法,使用正则表达式
        String reg ="[0-9a-zA-Z_]{8,18}";
        if(username!=null){
          if(username.matches(reg)){
              return new User(201,"tina","1234",1);
          }
        }
       return null;
    }
}
